<template>
  <div>
    <div
      class="container"
      v-if="fileSpace && !nodata"
      :style="{backgroundImage: activityType == 2 ? 'url(' + fileSpace + '/images/mgb-group-banner.png)' : 'url(' + fileSpace + '/images/mgb-seckill-banner.png)'}">
    <template v-if="!getCustomerId">
      <get-user-info v-if="isGetUserInfo"  @authPhoneInfo="authPhoneInfo"></get-user-info>
      <get-phone-info v-if="isGetPhoneInfo"></get-phone-info>
    </template>
    <template v-if="getCustomerId && !getPhone">
      <get-phone-info v-if="isGetPhoneInfo"></get-phone-info>
    </template>
      <div :class="activityType == 2 ? 'height-13' : 'height-107'"></div>
      <van-sticky>
        <div
          class="tabs-bar pad-b-7"
          v-if="fileSpace"
          :style="{backgroundImage: activityType == 2 ? 'url(' + fileSpace + '/images/mgb-group-banner.png)' : 'url(' + fileSpace + '/images/mgb-seckill-b.png)'}">
          <div class="tabs-tab" :class="{'tabs-tab_active': active === index}" v-for="(item, index) in tabsList" :key="index" @click="onChange(item, index)">
            <div class="font-26 height-35 mar-b-6">{{item.openTime}}</div>
            <div class="active-status flex-center"><sapn>{{item.activeStatus}}</sapn></div>
          </div>
        </div>
      </van-sticky>
      <div class="main">
        <div class="section">
          <div class="countdown-wrap">
            <div class="seckill-content">
              <div class="flex flex-center height-44 border-b" v-if="!nodata">
                <div class="font-13 font-w mar-r-6" v-if="tabInfo.countdownMsg">{{tabInfo.countdownMsg}}</div>
                <div class="count-down" v-if="tabInfo.countTime > 0">
                  <van-count-down
                    use-slot
                    :time="tabInfo.countTime"
                    @change="bizChange"
                    @finish="bizFinished"
                  >
                    <template v-if="(bizTimer.days !== '00') && bizTimer.days ">
                      <span class="square-block">{{bizTimer.days}}</span>
                      <span class="square-t square-d mar-l-2 mar-r-2">天</span>
                    </template>
                    <span class="square-block">{{bizTimer.hours}}</span>
                    <span class="square-t">:</span>
                    <span class="square-block">{{bizTimer.minutes}}</span>
                    <span class="square-t">:</span>
                    <span class="square-block">{{bizTimer.seconds}}</span>
                  </van-count-down>
                </div>
              </div>
              <div class="seckill-list pad-l-15 pad-r-14" v-if="!nodata">
                <div class="seckill-goods flex flex-between mar-t-15"
                  v-for="(good, goodIndex) in scekillList" :key="goodIndex"
                  @click="$pt.navigateTo({url: '/pages/shop/detail/main?goodsId=' + good.goodsId + '&goodsType=' + good.goodsType})">
                  <div class="goods-img width-100">
                    <img v-if="good.imageUrl" :src="good.imageUrl" class="width-100 height-100" alt=""/>
                    <!-- 跨境图标 -->
                    <div class="cross-border-pic">
                      <!-- 跨境保税 -->
                      <img
                        v-if="fileSpace && good.crossBorderType === 2 && good.crossBorderLabelType === 1"
                        :src="fileSpace + '/images/icon-cross-border.png'"
                        class="icon-cross-border"
                        alt="">
                      <!-- 海外直邮 -->
                      <img
                        v-if="fileSpace && good.crossBorderType === 2 && good.crossBorderLabelType === 2"
                        :src="fileSpace + '/images/icon-cross-border-22.png'"
                        class="icon-cross-border"
                        alt="">
                    </div>
                    <div class="sell-out" v-if="good.status === 0 || good.stock === 0 ">
                      <div class="del-layer align-c">
                        <div class="font-14">已售完</div>
                        <div class="font-9 mar-t--2">SOLD OUT</div>
                      </div>
                    </div>
                    <div
                      v-if="good.limitNum"
                      class="limit-buy-bar"
                      :style="{color: good.limitNum}">限购{{ good.limitNum }}件</div>
                  </div>
                  <div class="goods-content height-112 mar-l-8 flex-item">
                    <div class="line-1 font-16 font-w pad-t-6">{{good.title}}</div>
                    <div class="flex">
                      <template v-if="activityType == 2 && checkOwner">
                        <div class="nameplate mar-t-6 mar-b-17" v-if="good.commanderCommission && good.commanderCommission > 0 && getCustomerId">
                          <span class="left">{{getAppInfo.commissionAlias || '分销赚'}}</span>
                          <span class="right">{{good.commanderCommission}}元</span>
                        </div>
                        <div class="height-43" v-else></div>                        
                      </template>
                      <template v-else>
                        <div class="nameplate mar-t-6 mar-b-17" v-if="good.distributeIncome && good.distributeIncome > 0 && getCustomerId">
                          <span class="left">{{getAppInfo.commissionAlias || '分销赚'}}</span>
                          <span class="right">{{good.distributeIncome}}元</span>
                        </div>
                        <div class="height-43" v-else></div>
                      </template>                      
                    </div>                    
                    <div class="flex v-align-t flex-between mar-t-3">
                      <div class="price-row">
                        <div
                          class="now-price font-12">￥<span class="font-18">{{good.bestPrice}}</span></div>
                        <div class="font-over font-color-9 font-12 mar-l-3" v-if="good.scribingPrice">￥{{good.scribingPrice}}</div>
                      </div>
                      <div v-if="status !== -1" class="mar-t-4">
                        <template v-if="good.goodsStatus && good.stock">
                          <div
                            @click.stop.prevent="showCart(good)"
                            :style="{color:getAppInfo.style.color5, background:getAppInfo.style.color2}"
                            class="in-cart-btn font-14">加入购物车</div>
                        </template>
                      </div>
                      <template v-else>
                        <div class="font-15 coming-soon pad-t-14">即将开始</div>
                      </template>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="height-49"></div>
      <div class="foot-cart flex flex-between">
        <div class="content flex-item">
          <div class="flex flex-center">
            <van-icon class="mar-t--4" name="shopping-cart-o" size="22px" color="#999999" />
            <div class="font-13 mar-l-6">购物车<span v-if="cartBadge !== 0">({{cartBadge}})</span></div>
          </div>
          <div class="font-12 color-price">￥<span class="font-18">{{totalPrice}}</span></div>
        </div>
        <div
          class="go-cart"
          :style="{backgroundColor: globalStyle.color2, color: globalStyle.styleType === 10 ? globalStyle.color5 : '#fff'}"
          @click="$pt.switchTab({url: '/pages/shop/cart/main'})">去购物车</div>
      </div>
      <!--sku选择-->
      <get-sku-buy
        ref="getSkuBuy"
        :styleColor="globalStyle"
        :goodsType="goodsType"
        :room_id="room_id"
        :goodsData="goods"
        :skuPropList="skuPropList"
        :skuList="skuList"
        :values="values"
        :featuresType ="featuresType"
        @finished="getSkuBuyFinished"
        @close="getSkuBuyClose"></get-sku-buy>
    </div>
    <div class="nodata align-c" v-if="nodata">
      <img v-if="fileSpace" :src="fileSpace + '/images/mygroupbuy-noseckill.png'" class="width-250 height-174" alt=""/>
    </div>
  </div>
</template>
<script>
import GetUserInfo from '@/components/GetUserInfo'
import GetPhoneInfo from '@/components/GetPhoneInfo'
import { listPromotion, pagePromotionGoods, saveByPromotionGoodsId } from '@/api/home'
import { addShoppingCart, getProjectGoodsSku, getShopCartVeekray } from '@/api/shop'
import GetSkuBuy from '@/components/GetSkuBuy'
import { setCartBadge } from '@/utils/auth'
export default {
  components: { GetSkuBuy, GetUserInfo, GetPhoneInfo },
  data() {
    return {
      effectiveList: [],
      feeGoodsList: [],
      groupBuyGoodsList: [],
      promotionList: [],
      listQueryCart: {
        memberId: '',
        customerId: '',
        enterpriseId: ''
      }, // 获取购物车列表信息 参数集合
      active: 0,
      nodata: false,
      bizEndTime: 60 * 10 * 1000,
      bizTimer: {},
      tabsList: [],
      tabInfo: {},
      serverDate: null,
      params: {
        promotionId: '',
        enterpriseId: '',
        memberId: '',
        customerId: '',
        currentPage: 1,
        size: 10
      },
      pullLoad: {
        loading: false,
        finished: false
      },
      scekillList: [],
      enterpriseId: '',
      promotionId: '',
      activityType: '',
      cartBadge: 0,
      goodsType: '',
      room_id: null,
      goods: {},
      skuPropList: [],
      skuList: [],
      values: [],
      fastGoods: [],
      goodsLoad: 0,
      globalStyle: {},
      isGetUserInfo: false,
      isGetPhoneInfo: false,
      getAppInfo: {},
      status: null,
      featuresType: ''
    }
  },
  computed: {
    totalPrice() {
      let price = '0.00'
      this.cartBadge = 0
      this.scekillList.forEach(item => {
        let index = this.fastGoods.findIndex(listItem => {
          return listItem.goodsId === item.goodsId
        })
        if (index !== -1) {
          price = parseFloat(this.fastGoods[index].totalSellPrice * 1 + price * 1).toFixed(2)
          this.cartBadge += this.fastGoods[index].goodsNum
        }
      })
      return price
    }
  },
  onLoad() {
    // 初始化data
    Object.assign(this.$data, this.$options.data())
  },
  onShow() {
    // 限时抢购
    this.getAppInfo = this.$pt.getStorageSync('appInfo')
    this.globalStyle = this.getAppInfo.style
    this.enterpriseId = this.getCurrentPage().query.enterpriseId
    // '活动类型  0秒杀 1包邮 2社区团购'
    this.activityType = this.getCurrentPage().query.activityType || ''
    if (!this.activityType) {
      let linkType = null
      linkType = this.getCurrentPage().query.linkType
      if (Number(linkType) === 1502) {
        this.activityType = 2
      } else {
        this.activityType = 0
      }
    }
    if (Number(this.activityType) === 2) {
      this.$pt.setNavigationBarTitle({
        title: '社区团购'
      })
      this.promotionId = ''
    } else {
      this.$pt.setNavigationBarTitle({
        title: '限时抢购'
      })
      this.promotionId = this.getCurrentPage().query.promotionId || ''
    }
  },
  mounted() {
    this.params.memberId = this.getMemberId
    this.params.customerId = this.getCustomerId
    this.params.enterpriseId = this.enterpriseId
    this.params.currentPage = 1
    this.scekillList = []
    this.getListPromotion()
    this.getShopCartVeekray()
  },
  onPullDownRefresh() {
    // 下拉刷新
    this.$pt.pageScrollTo({
      scrollTop: 0,
      duration: 0
    })
    this.params.currentPage = 1
    this.scekillList = []
    this.getListPromotion()
    this.getShopCartVeekray()
    setTimeout(() => {
      this.$pt.stopPullDownRefresh()
    }, 500)
  },
  onReachBottom() {
    // 触底刷新
    if (!this.pullLoad.finished) {
      this.pagePromotionGoods()
    }
  },
  methods: {
    resetFastGoodsPrice() {
      this.fastGoods.forEach(itemGoods => {
        if (itemGoods.skuFlag) {
          // 多规格
          let totalSellPrice = null
          itemGoods.skuList.forEach(item => {
            totalSellPrice += Math.round((item.goodsNum * item.bestPrice) * 100) / 100
          })
          itemGoods.totalSellPrice = (Math.round(totalSellPrice * 100) / 100).toFixed(2)
        } else {
          // 单规格
          let totalSellPrice = null
          totalSellPrice = (Math.round((itemGoods.goodsNum * itemGoods.bestPrice) * 100) / 100).toFixed(2)
          itemGoods.totalSellPrice = totalSellPrice
        }
      })
    },
    getShopCartVeekray() {
      this.effectiveList = []
      this.groupBuyGoodsList = []
      this.listQueryCart.memberId = this.getMemberId
      this.listQueryCart.customerId = this.getCustomerId
      this.listQueryCart.enterpriseId = this.getEnterpriseId || ''
      getShopCartVeekray(this.listQueryCart).then(response => {
        if (response.isError) return
        this.feeGoodsList = []
        this.effectiveList = response.data.effectiveList
        this.groupBuyGoodsList = response.data.groupBuyGoodsList
        this.promotionList = response.data.promotionList
        if (this.promotionList.length) {
          this.promotionList.forEach(item => {
            if (item.feeGoodsList) {
              item.feeGoodsList.forEach(itemSub => {
                this.feeGoodsList.push(itemSub)
              })
            }
          })
        }
        // 设置快速购买缓存数据，以及购物车角标展示
        this.dataFastEls(response.data)
      }).catch(() => {
      })
    },
    dataFastEls(data) {
      this.fastGoods = []
      let storeHomeGoodsList = []
      if (data.storeHomeGoodsList) {
        storeHomeGoodsList = data.storeHomeGoodsList
      }
      let tempAllList = []
      tempAllList = tempAllList.concat(this.effectiveList, this.feeGoodsList, this.groupBuyGoodsList, storeHomeGoodsList)
      if (tempAllList.length) {
        tempAllList.forEach(item => {
          // 重新获取快速购买数据
          if (item.skuId) {
            // 多规格
            let skuData = []
            let objSkuData = {
              skuId: item.skuId,
              goodsNum: item.goodsNum,
              bestPrice: item.bestPrice
            }
            skuData.push(objSkuData)
            let goodsNum = null
            skuData.forEach(item => {
              goodsNum += item.goodsNum
            })
            this.fastGoods.push({
              goodsId: item.goodsId,
              skuFlag: 1,
              skuList: skuData,
              goodsNum: goodsNum
            })
          } else {
            // 单规格
            let objFastGoods = {
              goodsId: item.goodsId,
              skuFlag: 0,
              goodsNum: item.goodsNum,
              bestPrice: item.bestPrice
            }
            this.fastGoods.push(objFastGoods)
          }
        })
      }
      let map = {}
      let dest = []
      this.fastGoods.forEach(item => {
        if (!map[item.goodsId]) {
          if (item.skuFlag) {
            dest.push({
              goodsId: item.goodsId,
              goodsNum: item.goodsNum,
              skuFlag: 1,
              skuList: item.skuList
            })
          } else {
            let objDest = {
              goodsId: item.goodsId,
              goodsNum: item.goodsNum,
              skuFlag: 0,
              bestPrice: item.bestPrice
            }
            dest.push(objDest)
          }
          map[item.goodsId] = item
        } else {
          dest.forEach(itemSub => {
            if (itemSub.goodsId === item.goodsId) {
              itemSub.goodsNum = itemSub.goodsNum + item.goodsNum
              if (item.skuFlag) {
                itemSub.skuList = itemSub.skuList.concat(item.skuList)
              }
            }
          })
        }
      })
      this.fastGoods = []
      this.fastGoods = dest
      this.resetFastGoodsPrice()
    },
    onChange(item, index) {
      this.active = index
      this.tabInfo = this.tabsList[index]
      this.scekillList = []
      this.pullLoad.finished = false
      this.params.currentPage = 1
      this.pagePromotionGoods()
    },
    getListPromotion() {
      let params = {
        enterpriseId: this.enterpriseId,
        memberId: this.getMemberId,
        customerId: this.getCustomerId,
        promotionId: this.promotionId || '',
        activityType: this.activityType
      }
      this.scekillList = []
      this.$pt.showLoading()
      listPromotion(params).then(response => {
        this.$pt.hideLoading()
        // 活动列表查询
        if (response.isError) return
        this.serverDate = response.date
        this.tabsList = response.data
        let serverTime = new Date(this.serverDate).getTime()
        let serverDate = this.$utils.formatTimeToDate(this.serverDate, 'yyyy-MM-dd')
        if (this.tabsList.length === 0) {
          this.nodata = true
          this.pullLoad.finished = true
          return
        }
        this.tabsList.forEach((value, valueIndex) => {
          if (!value.startTime || !value.endTime) {
            return
          }
          let activeDate = this.$utils.formatTimeToDate(value.startTime, 'yyyy-MM-dd')
          let startTime = this.$utils.formatTimeStamp(value.startTime)
          let endTime = this.$utils.formatTimeStamp(value.endTime)
          value.openTime = this.$utils.formatTimeToDate(value.startTime, 'hh:mm')
          if (activeDate > serverDate) {
            value.countTime = startTime - serverTime
            value.countdownMsg = '距离本场开始'
            value.status = -1
            value.activeStatus = this.$utils.formatTimeToDate(value.startTime, 'MMdd')
          } else {
            if (startTime > serverTime) {
              value.countTime = startTime - serverTime
              value.countdownMsg = '距离本场开始'
              value.activeStatus = '即将开始'
              value.status = -1
            } else {
              value.countTime = endTime - serverTime
              value.countdownMsg = '距离本场结束'
              value.activeStatus = '抢购中'
              value.status = 0
            }
          }
          // 社区团购多活动，进入指定的活动tab
          if (Number(this.activityType) === 2 && this.getCurrentPage().query.promotionId && (this.getCurrentPage().query.promotionId === value.promotionId)) {
            this.active = valueIndex
            this.tabInfo = this.tabsList[valueIndex]
          }
        })
        this.tabInfo = this.tabsList[this.active]
        this.scekillList = []
        this.params.currentPage = 1
        this.pullLoad.finished = false
        this.pagePromotionGoods()
      })
    },
    pagePromotionGoods() {
      this.nodata = false
      this.status = this.tabsList[this.active].status
      this.params.promotionId = this.tabsList[this.active].promotionId
      pagePromotionGoods(this.params).then(response => {
        if (response.isError) return
        response.data.records.forEach(value => {
          if (value.limitNum) {
            value.groupLimitNum = value.limitNum
          } else {
            value.groupLimitNum = value.stock
          }
          const limitNumData = value.groupLimitNum
          this.$delete(value, 'groupLimitNum')
          this.$set(value, 'groupLimitNum', limitNumData)
          this.scekillList.push(value)
        })
        this.params.currentPage++
        if (this.scekillList.length === 0) {
          this.nodata = true
        }
        if (this.scekillList.length === 0 || this.scekillList.length >= response.data.total) {
          this.pullLoad.finished = true
        }
      })
    },
    // 头像昵称 授权后 立即跳出手机号授权
    authPhoneInfo() {
      this.isGetPhoneInfo = true
    },
    bizFinished() {
      this.getListPromotion()
    },
    bizChange(e) {
      // 秒杀倒计时
      let timer = e.mp.detail
      if (timer.days < 10) {
        timer.days = '0' + timer.days
      }
      if (timer.hours < 10) {
        timer.hours = '0' + timer.hours
      }
      if (timer.minutes < 10) {
        timer.minutes = '0' + timer.minutes
      }
      if (timer.seconds < 10) {
        timer.seconds = '0' + timer.seconds
      }
      this.bizTimer = timer
    },
    getSkuBuyClose() {
    },
    getSkuBuy(isCart, item) {
      if (this.getCustomerId) {
        if (this.shareMemberId) {
          item.shareMemberId = this.shareMemberId
        }
        const comissionFlag = this.getCurrentPage().query.comissionFlag
        this.$refs.getSkuBuy.show(item, isCart, comissionFlag, item.qty)
      } else {
        this.$pt.reLaunch({ url: '/pages/home/main' })
      }
    },
    getSkuBuyFinished(params) {
      // console.log('getSkuBuyFinished 11', params.goodsNum)
      this.scekillList.forEach(item => {
        if (params.goodsId === item.goodsId) {
          let addCount = 0
          if (item.goodsNum) {
            addCount = item.goodsNum + params.goodsNum
          } else {
            addCount = params.goodsNum
          }
          item.goodsNum = addCount
        }
        this.cartBadgeEls(1, item, params)
      })
      this.resetFastGoodsPrice()
      this.totalCartBadge(params.goodsNum)
    },
    getProjectGoodsSku(item) {
      this.goods = this.$utils.deepClone(item)
      this.$utils.showToast({
        title: '加载中',
        icon: 'loading'
      })
      getProjectGoodsSku({
        goodsId: item.goodsId,
        customerId: this.getCustomerId,
        memberId: this.getMemberId,
        microShopFlag: item.goodsType === 30 || item.goodsType === 31 || item.goodsType === 32 ? 0 : 1
      }).then((response) => {
        if (response.isError) return
        this.$pt.hideToast()
        this.goods.skuPropList = response.data.skuPropList
        this.goods.skuList = response.data.skuList
        this.goods.values = response.data.values
        // 社区团购商品，设置featuresType为11
        this.featuresType = ''
        if (Number(this.activityType) === 2) {
          this.featuresType = 11
        }
        this.skuPropList = response.data.skuPropList
        this.skuList = response.data.skuList
        this.values = response.data.values
        setTimeout(() => {
          this.getSkuBuy(true, this.goods)
        }, 100)
      }).catch(() => {
      })
    },
    showCart(good) {
      if (this.getCustomerId) {
        if (this.getPhone) {
          if (good.skuFlag === 1) {
            this.skuPropList = []
            this.skuList = []
            this.values = []
            this.goods = good
            this.goodsType = good.goodsType
            // this.goods.bestPrice = ''
            this.goods.bestPrice = good.bestPrice
            this.goods.images = []
            this.goods.images[0] = good.imageUrl
            this.goods.isCart = true
            this.getProjectGoodsSku(good)
          } else {
            good.goodsNum = 1
            this.simpleSkuEls(good)
          }
        } else {
          this.isGetPhoneInfo = true
        }
      } else {
        this.isGetUserInfo = true
      }
    },
    simpleSkuEls(itemOne) {
      this.goodsLoad = 0
      this.scekillList.forEach(item => {
        if (itemOne.goodsId === item.goodsId) {
          item.goodsNum = itemOne.goodsNum
          this.goodsLoad++
          if (this.goodsLoad === 1) {
            this.addShoppingCart(1, itemOne)
          }
        }
      })
    },
    addShoppingCart(value, good) {
      this.addElsShoppingCart(value, good)
    },
    addElsShoppingCart(value, good) {
      const shoppingCart = {
        customerId: this.getCustomerId,
        goodsId: good.goodsId,
        goodsNum: value,
        memberId: this.getMemberId,
        goodsType: good.goodsType,
        shoppingCartType: good.goodsType === 30 || good.goodsType === 31 || good.goodsType === 32 ? 3 : 1
      }
      addShoppingCart(shoppingCart).then((response) => {
        if (response.isError) return
        if (value === 1) this.$utils.showToast({title: '加入购物车成功'})
        this.cartBadgeEls(value, good)
        this.resetFastGoodsPrice()
        this.totalCartBadge(value)
      }).catch(() => {
      })
    },
    totalCartBadge(value) {
      let cartBadge = 0
      let badgeNum = this.$pt.getStorageSync('cartBadge') || 0
      console.log('totalCartBadge 11', badgeNum, value)
      cartBadge = Number(badgeNum) + Number(value)
      setCartBadge(cartBadge)
    },
    // 判断数组是否存在某个key值
    checkArrInclude(arr, item, keyName) {
      let arrData = []
      if (arr.length !== 0) {
        arr.forEach(item => {
          arrData.push(item[keyName])
        })
      }
      if (arrData.includes(item)) {
        return true
      } else {
        return false
      }
    },
    cartBadgeEls(value, item, params) {
      // 多规格类型
      if (params !== undefined) {
        // 多规格加、减数量缓存处理
        // console.log(params)
        if (this.fastGoods.length !== 0) {
          // 判段商品是否已经存在
          if (this.checkArrInclude(this.fastGoods, params.goodsId, 'goodsId')) {
            // 已存在goodsId商品
            this.fastGoods.forEach(itemGoods => {
              if (itemGoods.goodsId === params.goodsId) {
                // 已存在skuId商品
                if (this.checkArrInclude(itemGoods.skuList, params.skuId, 'skuId')) {
                  itemGoods.goodsNum = null
                  itemGoods.skuList.forEach(itemSku => {
                    if (itemSku.skuId === params.skuId) {
                      itemSku.goodsNum = itemSku.goodsNum + params.goodsNum
                      itemSku.bestPrice = params.bestPrice
                    }
                    itemGoods.goodsNum += itemSku.goodsNum
                  })
                } else {
                  let objSkuList = {
                    skuId: params.skuId,
                    goodsNum: params.goodsNum,
                    bestPrice: params.bestPrice
                  }
                  itemGoods.skuList.push(objSkuList)
                  itemGoods.goodsNum = null
                  itemGoods.skuList.forEach(itemSku => {
                    itemGoods.goodsNum += itemSku.goodsNum
                  })
                }
              }
            })
          } else {
            // 新增商品
            let skuData = []
            let objSkuData = {
              skuId: params.skuId,
              goodsNum: params.goodsNum,
              bestPrice: params.bestPrice
            }
            skuData.push(objSkuData)
            let goodsNum = null
            skuData.forEach(item => {
              goodsNum += item.goodsNum
            })
            this.fastGoods.push({
              goodsId: params.goodsId,
              skuFlag: 1,
              skuList: skuData,
              goodsNum: goodsNum
            })
          }
        } else {
          let skuData = []
          let objSkuData = {
            skuId: params.skuId,
            goodsNum: params.goodsNum,
            bestPrice: params.bestPrice
          }
          skuData.push(objSkuData)
          let goodsNum = null
          skuData.forEach(item => {
            goodsNum += item.goodsNum
          })
          let objFastGoods = {
            goodsId: params.goodsId,
            skuFlag: 1,
            skuList: skuData,
            goodsNum: goodsNum
          }
          this.fastGoods.push(objFastGoods)
        }
        return
      }
      // 单规格类型
      if (value === 1) {
        // 单规格加数量处理
        if (this.fastGoods.length !== 0) {
          // 判段商品是否已经存在
          if (this.checkArrInclude(this.fastGoods, item.goodsId, 'goodsId')) {
            // 已存在商品
            this.fastGoods.forEach(itemGoods => {
              if (itemGoods.goodsId === item.goodsId) {
                itemGoods.goodsNum = itemGoods.goodsNum + value
                itemGoods.bestPrice = item.bestPrice
              }
            })
          } else {
            // 新增商品
            let objData = {
              goodsId: item.goodsId,
              skuFlag: 0,
              goodsNum: item.goodsNum,
              bestPrice: item.bestPrice
            }
            this.fastGoods.push(objData)
          }
        } else {
          let objData = {
            goodsId: item.goodsId,
            skuFlag: 0,
            goodsNum: item.goodsNum,
            bestPrice: item.bestPrice
          }
          this.fastGoods.push(objData)
        }
      }
    },
    // 活动删除
    removeItem(item) {
      let statusTips = ''
      if (item.status) {
        statusTips = '移除后将对买家不显示该商品是否确认移除该商品？'
      } else {
        statusTips = '重新加入后将对买家显示该商品'
      }
      this.$pt.showModal({
        content: statusTips,
        success: res => {
          if (res.confirm) {
            let statusVal = null
            if (item.status) {
              statusVal = 0
            } else {
              statusVal = 1
            }
            saveByPromotionGoodsId({
              promotionGoodsId: item.promotionGoodsId,
              memberId: this.getCustomerId,
              status: statusVal
            }).then(response => {
              if (response.isError) return
              this.scekillList = []
              this.pullLoad.finished = false
              this.params.currentPage = 1
              this.getListPromotion()
            })
          }
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
.container {
  background-size: 100%;
  background-repeat: no-repeat;
  background-color: white;
  min-height: 100vh;
  .tabs-bar {
    height: 62px;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    text-align: center;
    background-size: 100%;
    background-repeat: no-repeat;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
    &::-webkit-scrollbar {
      display: none; /* Chrome Safari */
    }
    .tabs-tab {
      display: inline-block;
      color: rgba(255, 255, 255, 0.72);
      text-align: center;
      width: 22%;
      .active-status {
        height: 20px;
        // line-height: 20px;
        font-size: 12px;
        margin: auto;
      }
      &_active {
        color: white;
        .active-status {
          width: 63px;
          height: 20px;
          text-align: center;
          // line-height: 20px;
          background: linear-gradient(to bottom, #fffdfd, #ffc2b9);
          border-radius: 10px;
          color: #ea2f0e;
        }
      }
    }
  }
}
.coming-soon{
  color: #ff243d;
}
.main {
  .section {
    .countdown-wrap {
      .seckill-content {
        border-radius: 15px 15px 0 0;
        background: white;
        // min-height: calc(100vh - 170px);
        margin-top: 2px;
        .border-b {
          border-bottom: 0.5px solid #f3f3f3;
        }
        .count-down {
          .square-block {
            background: #333;
            border-radius: 1px;
            font-size: 13px;
            color: white;
            // width: 18px;
            padding: 0 2px;
            height: 18px;
            line-height: 18px;
            text-align: center;
            display: inline-block;
          }
          .square-t {
            display: inline-block;
            color: #333;
            width: 11px;
            height: 15px;
            line-height: 15px;
            text-align: center;
          }
          .square-d {
            width: unset;
          }
        }
      }
      .seckill-list {
        .seckill-goods {
          .goods-img {
            position: relative;
            border-radius: 10px;
            overflow: hidden;
            .limit-buy-bar{
              position: absolute;
              left: 0;
              bottom: 0;
              width: 100%;
              text-align: center;
              padding: 1px 7px;
              color: #fff;
              background: rgba(0, 0, 0, 0.5);
              font-size: 12px;
              box-sizing: border-box;
            }
            .sell-out {
              position: absolute;
              width: 100px;
              height: 100px;
              left: 0;
              top: 0;
              display: flex;
              justify-content: center;
              align-items: center;
              overflow: hidden;
              color: rgba(254, 254, 254, 0.7);
              background: rgba(0, 0, 0, 0.5);
              font-size: 12px;
              border-radius: 10px;
              z-index: 20;
              .del-layer {
                border-radius: 50%;
                border: 1px solid white;
                justify-content: center;
                width: 60px;
                height: 60px;
              }
              .delete-css {
                position: absolute;
                transform: rotate(-45deg);
                background: rgba(255, 255, 255, 0.58);
                height: 20px;
                line-height: 20px;
                font-size: 12px;
                width: 100%;
                text-align: center;
                color: #000;
              }
            }            
          }
          .goods-content {
            .nameplate {
              height: 18px;
              line-height: 18px;
              padding: 0 6px;
              color: #fff;
              font-size: 12px;
              background: linear-gradient(135deg, #FE6D41, #ED4836);
              border-radius: 0px 4px 4px 4px;
            }
            .price-row {
              line-height: 1;
              // display: flex;
              // align-items: flex-end;
              // justify-content: left;
              .now-price {
                color: #eb4e4e;
                // max-width: 65px;
                // overflow: hidden;
                // text-overflow: ellipsis;
                // display: -webkit-box;
                // -webkit-line-clamp: 1;
                // -webkit-box-orient: vertical;
                // word-break: break-word;
              }
              .font-over {
                max-width: 51px;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 1;
                -webkit-box-orient: vertical;
                word-break: break-word;
              }
            }
            .icon-bar {
              .icon-base {
                width: 24px;
                height: 24px;
                border-radius: 50%;
                font-size: 0;
                display: flex;
                justify-content: center;
                align-items: center;
                font-weight: 900;
              }
              .icon-add {
                background: #ffd800;
              }
              .icon-delete {
                background: #fff9d7;
                transform: rotate(45deg);
              }
            }
          }
        }
      }
    }
  }
}
.nodata {
  margin-top: 135px;
}
.foot-cart {
  position: fixed;
  height: 49px;
  width: 100%;
  background-color: white;
  left: 0;
  bottom: 0;
  box-shadow: 0 0 5px rgba(155, 155, 155, 0.15);
  .content {
    padding-left: 15px;
    padding-right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .color-price {
      color: #ff593e;
    }
  }
  .go-cart {
    font-size: 16px;
    // background-color: #FFE200;
    height: 49px;
    line-height: 49px;
    width: 133.5px;
    text-align: center;
  }
}
</style>
